package com.gem.mapper;

import com.gem.domain.Teacher;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author Bravea❤ ·勇
 * Description: 授课人信息mapper
 * create
 * Modified By:
 */
@Mapper
public interface TeacherMapper {
    //插入
    @Insert("INSERT INTO teacher (t_name,t_phone,t_qq,t_wechat,t_email,t_major,t_money,t_address,t_remarks) VALUES" +
            " (#{tName},#{tPhone},#{tQq},#{tWechat},#{tEmail},#{tMajor},#{tMoney},#{tAddress},#{tRemarks})")
    boolean addTeacher(Teacher c);

    //查找所有
    @Select("SELECT * FROM teacher WHERE t_status>0")
    List<Teacher> selectAllTeacher();

    //查询单个
    @Select("SELECT * FROM teacher WHERE t_id = #{tId} AND t_status>0")
    Teacher selectTeacherById(String tId);

    //模糊查询老师
    @Select("SELECT * FROM teacher WHERE t_name LIKE CONCAT('%',#{ccrcCourseTeacher},'%') AND t_status>0")
    List<Teacher> selectTeacherByName(String ccrcCourseTeacher);

    //修改
    @Update("UPDATE teacher SET t_name=#{tName},t_phone=#{tPhone},t_qq=#{tQq},t_wechat=#{tWechat},t_email=#{tEmail},t_major=#{tMajor},t_money=#{tMoney}," +
            "t_address=#{tAddress},t_remarks=#{tRemarks} WHERE t_id=#{tId} AND t_status>0")
    boolean modifyTeacherById(Teacher c);

    //@Delete("DELETE FROM teacher WHERE t_id=#{tIid}")//真删
    //伪删除
    @Update("UPDATE teacher SET t_status=-1 WHERE t_id=#{tId}")
    boolean deleteTeacherById(String tId);

    //查询带条件
    @Select("SELECT * FROM teacher WHERE t_name LIKE #{param1} AND t_major LIKE #{param2} AND t_status>0")
    List<Teacher> searchTeacher(String tName, String tMajor);
}
